using System;
using System.Collections.Generic;
using System.Text;

namespace FE
{
    public class Player
    {
        private List<Player> Allies = new List<Player>();

        public bool IsAlly(Player player)
        {
            if (player == this) return true;
            return Allies.Contains(player);
        }
        private string name;
        public string Name
        {
            get { return name; }
            set { name = value; }
        }
        public bool HasAnyMoves
        {
            get
            {
                
                foreach (UnitStatus us in UnitStatuses)
                {
                    if (us.hasTurn && !us.IsDead) return true;
                }
                return false;
            }
        }
        public void NewTurn()
        {
            foreach (UnitStatus us in UnitStatuses)
            {
                us.hasTurn = true;
            }
        }
        public bool HasLiveUnits
        {
            get
            {
                foreach (UnitStatus us in UnitStatuses)
                {
                    if (!us.IsDead) return true;
                }
                return false;
            }
        }
        public bool OwnsUnit(UnitStatus unit)
        {            
            return UnitStatuses.Contains(unit);
        }
        public UnitStatus AddUnit(Unit unit)
        {
            UnitStatus us = new UnitStatus(unit);
            UnitStatuses.Add(us);
            return us;
        }
        public UnitStatus GetUnitStatus(Unit unit)
        {
            foreach (UnitStatus us in UnitStatuses)
            {
                if (us.unit == unit) return us;
            }
            return null;
        }
        public List<UnitStatus> UnitStatuses = new List<UnitStatus>();
    }
}
